package com.legal.domain.vo;

import com.legal.domain.po.QuestionCategory;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * <p>题库分类视图对象</p>
 * <p>包含分类信息和对应的问题数量</p>
 */
@Data
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@Schema(name = "QuestionCategoryVO", description = "题库分类视图对象")
public class QuestionCategoryVO extends QuestionCategory implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "该分类下的问题数量", example = "100")
    private Integer questionCount;


    public QuestionCategoryVO(QuestionCategory category, Integer questionCount) {
        // 手动复制属性或使用BeanUtils
        this.setId(category.getId());
        this.setCategoryNo(category.getCategoryNo());
        this.setCategoryName(category.getCategoryName());
        this.setDescription(category.getDescription());
        this.setSortOrder(category.getSortOrder());
        this.setIsActive(category.getIsActive());
        this.setCreator(category.getCreator());
        this.setCreateTime(category.getCreateTime());
        this.setUpdater(category.getUpdater());
        this.setUpdateTime(category.getUpdateTime());
        this.questionCount = questionCount;
    }


}